"""
@name: homework
@author: liangrui
@projectname: pythonProject
"""

# # 1、使用reduce函数取出lst里的数字 --》 12349
from functools import reduce
lst=['a', '1', '2bb', '234', '', '9']
num = list(filter(lambda x:x.isdigit(), lst))
print(reduce(lambda x,y:x+y, num))

# # 2、有以下列表:list1 = [7, -8, 5, 4, 0, -2, -5]
# # 要求:1.正数在前，负数在后  2.正数从小到大  3.负数从大到小
list = [7,-8,5,4,0,-2,-5]
def sort_1(num):
    lst1 = []
    lst2 = []
    for i in num:
        if i<0:
            lst2.append(i)
        else:
            lst1.append(i)
    return sorted(lst1)+sorted(lst2,reverse=True)
print(sort_1(list))
#
# # 3、这是一个字符串排序，排序规则:小写<大写<奇数<偶数
str1 = 'asdf234GDSdsf23'
def sort_2(str):
    int1 = []
    int2 = []
    upper = []
    lower = []
    for i in str:
        if i.isdigit():
            if int(i)%2==0:
                int2.append(i)
            else:
                int1.append(i)
        elif i.isupper():
            upper.append(i)
        else:
            lower.append(i)
    return sorted(lower)+sorted(upper)+sorted(int1)+sorted(int2)
print(sort_2(str1))
